﻿package kit4j.notepad;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 程序运行入口。
 * 
 * @author MiniKnife
 * 
 */
public class Main {

	public static final String MAIN_CONFIG_FILE_PATH = "config.xml";
	
	private static final Logger log = LoggerFactory.getLogger(Main.class);

	public static void main(String[] args) {
		log.info("Notepad - kit4j");

		Runnable notepad = loadNotepad();
		
		notepad.run();
	}
	
	static Runnable loadNotepad() {
		ApplicationContext context = loadApplicationContext();
		
		return (Runnable) context.getBean("notepadProxy");
	}
	
	static ApplicationContext loadApplicationContext() {
		log.debug("Load ApplicationContext...");
		
		ApplicationContext context = new ClassPathXmlApplicationContext(
				MAIN_CONFIG_FILE_PATH);
		
		return context;
	}
}
